Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a new CLI subcommand pipe #84

Merged
merged 3 commits into from
Mar 16, 2024
Merged

Conversation

sokorototo
Copy link
Collaborator

@sokorototo sokorototo commented Mar 13, 2024

Added a new pipe subcommand, that allows you to read only a specific resource from an Archive into stdout. You can then pipe the stream wherever you deem necessary: jq, into a file or dumped into your terminal.

Sample Usage:

# Here -r stands for Resource
vach pipe -i documents.vach -r malbolgea.json

{
  "name": "Malbolgea",
  "type": "Fantasy World",
  "description": "Malbolgea is a fantastical realm filled with magic, mythical creatures, and ancient civilizations. It is a world of adventure and danger, where heroes rise to challenge dark forces and explore forgotten ruins.",
  "regions": [
    {
      "name": "The Verdant Forest",
      "description": "A lush and vibrant forest teeming with life. Ancient trees reach for the sky, and sunlight filters through the dense canopy, casting dappled shadows on the forest floor. But beware, for within the depths of the forest, strange and magical creatures lurk."
    },
    {
      "name": "The Crimson Mountains",
      "description": "Towerous peaks shrouded in mist and mystery. The Crimson Mountains are home to ancient dwarven strongholds, hidden valleys, and treacherous passes. Adventurers brave enough to explore these rugged lands may uncover forgotten treasures or awaken ancient evils."
    },
    {
      "name": "The Shifting Sands",
      "description": "Endless dunes stretch as far as the eye can see, shifting and changing with the wind. Beneath the scorching sun, ruins of lost civilizations lie buried, waiting to be discovered by intrepid explorers. But the sands hold more than secrets—they hold danger and deception."
    }
  ],
  "characters": [
    {
      "name": "Aria Moonshadow",
      "race": "Elf",
      "class": "Ranger",
      "description": "A skilled archer and tracker, Aria roams the forests of Malbolgea, protecting its creatures and preserving its natural beauty. With her keen senses and elven grace, she is a formidable ally and a fierce opponent to those who threaten the balance of nature."
    },
    {
      "name": "Dorn Stonehammer",
      "race": "Dwarf",
      "class": "Warrior",
      "description": "A veteran of many battles, Dorn is a stalwart defender of his people and their mountain strongholds. With his mighty axe and indomitable spirit, he faces danger head-on, whether battling orcs in the depths of the mountains or exploring ancient ruins in search of lost treasures."
    },
    {
      "name": "Zephyr Sandwalker",
      "race": "Human",
      "class": "Sorcerer",
      "description": "A master of arcane magic, Zephyr wields power beyond mortal comprehension. With a flick of his wrist, he can summon storms, control the elements, or unleash devastating spells upon his enemies. But his powers come with a price, and he must constantly guard against the lure of dark magic."
    }
  ]
}

@sokorototo sokorototo changed the title Added a bew CLI subcommand pipe Added a new CLI subcommand pipe Mar 13, 2024
@zeskeertwee
Copy link
Owner

zeskeertwee commented Mar 13, 2024

Looks good, but why remove log? Especially when outputting to stdout log is usefull to supress messages from being printed to stdout.

@sokorototo
Copy link
Collaborator Author

I removed log since mostly errors or success messages are logged. I just log errors with eprintln since it prints out to stderr anyways, other messages are logged via the progress bar

@zeskeertwee
Copy link
Owner

Log also allows underlying dependencies to log things though, and it's a very small dependency anyway.

@sokorototo
Copy link
Collaborator Author

Log also allows underlying dependencies to log things though, and it's a very small dependency anyway.

Running cargo tree in the root of the vach-cli crate, I can't see any crates using the log crate. So I just decided to not use it, rather than use it and add a few colours on exactly one error message. The log crate is generally useful for server applications and other long lived high availability applications. I think println and eprintln are enough for us.

@zeskeertwee zeskeertwee merged commit a69f263 into zeskeertwee:main Mar 16, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants